package com.richapp.launcher.database.system.dao;

import android.content.Context;
import android.util.Log;

import com.j256.ormlite.stmt.QueryBuilder;
import com.richapp.launcher.database.system.SystemBaseDao;
import com.richapp.launcher.database.system.mode.BoxLogin;

/**
 * Created by jack on 15/11/19.
 */
public class BoxLoginDao extends SystemBaseDao<BoxLogin> {

    public BoxLoginDao(Context context) {
        super(context, BoxLogin.class);
    }

    public BoxLogin getBoxLoginByClientId(String clientId){
        BoxLogin boxLogin = null;
        try {
            QueryBuilder<BoxLogin,Integer> queryBuilder = gettOp().queryBuilder();
            queryBuilder.where().eq("clientId",clientId);
            boxLogin = queryBuilder.queryForFirst();
        }catch (Exception e){
            Log.e(getClass().getName(), e.getMessage());
        }
        return boxLogin;
    }

    public BoxLogin getBoxLoginByBoxCpuId(String boxCpuId){
        BoxLogin boxLogin = null;
        try {
            QueryBuilder<BoxLogin,Integer> queryBuilder = gettOp().queryBuilder();
            queryBuilder.where().eq("boxCpuId",boxCpuId);
            boxLogin = queryBuilder.queryForFirst();
        }catch (Exception e){
            Log.e(getClass().getName(), e.getMessage());
        }
        return boxLogin;
    }
}
